###################################################################################
# 作者：sipeiliu
# 邮箱：sipeiliu@163.com
# 描述：编译规则
# 日期：2023.4.23
###################################################################################

#设置makefile文件搜索路径
VPATH = inc : src/init : src/device : src/thread

#设置可执行文件
sighter : main.o cruise.o distance.o key.o secure.o speed.o uart.o optocoupler.o ultrasonic.o motor.o
	gcc main.o cruise.o distance.o key.o secure.o speed.o uart.o optocoupler.o ultrasonic.o motor.o -l wiringPi -o sighter

#设置中间目标文件
#main
main.o : main.c
	gcc -c /opt/sighter/src/init/main.c -I /opt/sighter/inc
#device
motor.o : motor.c motor.h
	gcc -c /opt/sighter/src/device/motor.c -I /opt/sighter/inc
optocoupler.o : optocoupler.c optocoupler.h
	gcc -c /opt/sighter/src/device/optocoupler.c -I /opt/sighter/inc
ultrasonic.o : ultrasonic.c ultrasonic.h
	gcc -c /opt/sighter/src/device/ultrasonic.c -I /opt/sighter/inc
#thread
key.o : key.c key.h motor.o
	gcc -c /opt/sighter/src/thread/key.c -I /opt/sighter/inc
cruise.o : cruise.c cruise.h motor.o 
	gcc -c /opt/sighter/src/thread/cruise.c -I /opt/sighter/inc
speed.o : speed.c speed.h optocoupler.h motor.o
	gcc -c /opt/sighter/src/thread/speed.c -I /opt/sighter/inc
distance.o : distance.c distance.h ultrasonic.o motor.o
	gcc -c /opt/sighter/src/thread/distance.c -I /opt/sighter/inc
secure.o : secure.c secure.h
	gcc -c /opt/sighter/src/thread/secure.c -I /opt/sighter/inc
uart.o : uart.c uart.h
	gcc -c /opt/sighter/src/thread/uart.c -I /opt/sighter/inc

#设置伪目标
.PHONY : clean	
clean :
	-rm sighter *.o